#!/bin/bash
set -e

# 获取版本号
VERSION=$(grep -m 1 'version' setup.py | cut -d'"' -f2)
echo "Building release for version $VERSION"

# 清理旧的构建文件
rm -rf build/ dist/ *.egg-info/

# 编译 Rust 库
echo "Compiling Rust library..."
cd rust_engine
cargo build --release
cd ..

# 创建 Python 包
echo "Building Python package..."
python setup.py sdist bdist_wheel

# 运行测试
echo "Running tests..."
pytest

echo "Release build completed. Distribution files are in the 'dist' directory."
echo "To publish to PyPI, run: twine upload dist/*"
